<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表渲染</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>遍历列表</h2>
        <ul>
            <li v-for="p in persons" :key="p.id">
                {{p.name}}-{{p.age}}
            </li>
        </ul>
        <h2>遍历对象</h2>
        <ul>
            <li v-for="(val,k) in car" :key="k">
                {{k}}-{{val}}
            </li>
        </ul>
        <h2>遍历字符串</h2>
        <ul>
            <li v-for="(char,index) in str" :key="index">
                {{char}}-{{index}}
            </li>
        </ul>
    </div>
   <script type="text/javascript">
    new Vue({
        el:'#root',
        data: {
            persons:[
                {id:1, name:'张三',age:18},
                {id:2, name:'李四',age:19},
                {id:3, name:'王五',age:20}
            ],
            car: {name:'奥迪A8', price:'70万', color:'黑色'},
            str:'hello'
        }
    })
   </script>
</body>
</html>